import { Base } from "../../utils/base.js"

class Article extends Base {
  constructor() {
    super();
  }

  //文章列表
  getArticleData(page,tit, isTop,callback) {
    var params = {
      url: 'site/articles?page=' + page + '&title=' + tit + '&num=20' + '&isTop='+isTop,
      type: 'post',
      data: {},
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //获取分类
  getCategoryData(callback){
    var params = {
      url: 'site/category?num=100',
      type: 'post',
      data: {},
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

//新闻列表滚动加载
getNewsMoreData(id,page,callback){
  var params = {
    url: 'site/more?num=10&category_id='+ id +'&page='+ page,
    type: 'post',
    data: {},
    sCallback: function (data) {
      callback && callback(data);
    }
  }
  this.request(params);
}
  //点赞
  toVoteAdd(id, callback) {
    var params = {
      url: 'vote/add',
      type: 'post',
      data: {'id':id},
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //我的点赞文章
  getVoteList(page,callback) {
    var params = {
      url: 'vote/lists?page=' + page +'&expand=article'+'&num=20',
      type: 'post',
      data: {},
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //收藏
  toFavouriteAdd(id, callback) {
    var params = {
      url: 'favourite/add',
      type: 'post',
      data: { 'id': id },
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //发送评论
  tosendComment(id, content, callback) {
    var params = {
      url: 'comment/create',
      type: 'post',
      data: { 'entity_id': id, 'content': content },
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }
  //评论列表
  commentList(id,page,callback) {
    var params = {
      url: 'comment/index?entity_id=' + id + '&page='+page+'&expand=sons,member'+'&num=10',
      type: 'Get',
      data: {},
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //广告区
  getGuanggaoData(callback) {
    var params = {
      url: 'carousel-item/items',
      data: { 'id': 1, 'num': 4, 'key': 'articleBanner' },
      type: 'post',
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

};

export { Article };